//
//  DiscoverTableViewCellFifth.m
//  XYFMApp
//
//  Created by 岁变 on 16/9/1.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "DiscoverTableViewCellFifth.h"
#import "XYMacro.h"

@interface DiscoverTableViewCellFifth ()
@property (nonatomic, strong) UIImageView *frontImageView;
@property (nonatomic, strong) UIView *redLine;
@property (nonatomic, strong) UIImageView *bigImageView;
@property (nonatomic, strong) UIImageView *backImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *imageViewOne;
@property (nonatomic, strong) UIImageView *imageViewTwo;
@property (nonatomic, strong) UIImageView *imageViewThree;
@property (nonatomic, strong) UIImageView *imageViewFour;
@property (nonatomic, strong) UILabel *labelOne;
@property (nonatomic, strong) UILabel *labelTwo;
@property (nonatomic, strong) UILabel *labelThree;
@property (nonatomic, strong) UILabel *labelFour;



@end

@implementation DiscoverTableViewCellFifth

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _backImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_backImageView];
        
        _frontImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"find_cat_cover"]];
        [self.contentView addSubview:_frontImageView];
        
        _redLine = [[UIView alloc] init];
        _redLine.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_redLine];
        
        _bigImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"catinfo_item_bg"]];
        [self.contentView addSubview:_bigImageView];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        [_bigImageView addSubview:_titleLabel];
        
        _imageViewOne = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"catinfo_play_cnt"]];
        [_bigImageView addSubview:_imageViewOne];
        
        _labelOne = [[UILabel alloc] init];
        _labelOne.textColor = [UIColor colorWithRed:0.59 green:0.63 blue:0.71 alpha:1.00];
        _labelOne.font = [UIFont systemFontOfSize:12];
        [_bigImageView addSubview:_labelOne];
        
        _imageViewTwo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search_music_info1"]];
        [_bigImageView addSubview:_imageViewTwo];
        
        _labelTwo = [[UILabel alloc] init];
        _labelTwo.textColor = [UIColor colorWithRed:0.59 green:0.63 blue:0.71 alpha:1.00];
        _labelTwo.font = [UIFont systemFontOfSize:12];
        [_bigImageView addSubview:_labelTwo];
        
        _imageViewThree = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search_music_info3"]];
        [_bigImageView addSubview:_imageViewThree];
        
        _imageViewFour = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"catinfo_time"]];
        [_bigImageView addSubview:_imageViewFour];
 
        _labelThree = [[UILabel alloc] init];
        _labelThree.textColor = [UIColor colorWithRed:0.59 green:0.63 blue:0.71 alpha:1.00];
        _labelThree.font = [UIFont systemFontOfSize:12];
        [_bigImageView addSubview:_labelThree];

        _labelFour = [[UILabel alloc] init];
        _labelFour.textColor = [UIColor colorWithRed:0.59 green:0.63 blue:0.71 alpha:1.00];
        _labelFour.font = [UIFont systemFontOfSize:12];
        [_bigImageView addSubview:_labelFour];

        
        
    }
    return self;
}

- (void)setModel:(DiscoverListModelSecondData *)model {
    
    _model = [[DiscoverListModelSecondData alloc] init];
    _model = model;
    
    
    [_backImageView sd_setImageWithURL:[NSURL URLWithString:model.music_img] placeholderImage:PLACEHOLDERIMAGE];
    _titleLabel.text = model.music_title;
    _labelOne.text = [NSString stringWithFormat:@"%ld", model.music_views];
    _labelTwo.text = [NSString stringWithFormat:@"%ld", model.music_recomms];
    _labelThree.text = [NSString stringWithFormat:@"%ld", model.music_comments];
    NSInteger min = _model.music_duration / 60;
    NSInteger sec = _model.music_duration % 60;
    _labelFour.text = [NSString stringWithFormat:@"%ld:%ld", min, sec];

}


- (void)setModelArr:(NSArray *)modelArr {
    
    
}





- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [_backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(30);
        make.left.equalTo(self.contentView.mas_left).with.offset(55);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-5);
        make.width.equalTo(_backImageView.mas_height);
        
    }];
    [_backImageView layoutIfNeeded];
    _backImageView.clipsToBounds = YES;
    _backImageView.layer.cornerRadius = _backImageView.frame.size.height / 2;
    
    
    [_frontImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(25);
        make.left.equalTo(self.contentView.mas_left).with.offset(50);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
        make.width.equalTo(_frontImageView.mas_height);
    }];
    
    [_redLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(2);
        make.height.mas_offset(21);
        make.width.mas_offset(2);
        make.centerX.equalTo(_backImageView.mas_centerX);
    }];
    
    [_bigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(25);
        make.left.equalTo(_frontImageView.mas_right).with.offset(30);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_bigImageView.mas_top).with.offset(0);
        make.left.equalTo(_bigImageView.mas_left).with.offset(30);
        make.height.mas_offset(30);
        make.right.equalTo(_bigImageView.mas_right).with.offset(-20);
        
    }];
    
    [_imageViewOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_bigImageView.mas_left).with.offset(30);
        make.height.mas_offset(10);
        make.width.mas_offset(10);
    }];
    
    [_labelOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_imageViewOne.mas_right).with.offset(0);
        make.height.mas_offset(10);
        make.width.mas_offset(30);

    }];
    
    [_imageViewTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_labelOne.mas_right).with.offset(5);
        make.height.mas_offset(10);
        make.width.mas_offset(10);

    }];
    
    [_labelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_imageViewTwo.mas_right).with.offset(0);
        make.height.mas_offset(10);
        make.width.mas_offset(30);
    }];
    
    [_imageViewThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_labelTwo.mas_right).with.offset(5);
        make.height.mas_offset(10);
        make.width.mas_offset(10);
    }];
    
    [_labelThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_imageViewThree.mas_right).with.offset(0);
        make.height.mas_offset(10);
        make.width.mas_offset(30);
    }];
    
    [_imageViewFour mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_labelThree.mas_right).with.offset(5);
        make.height.mas_offset(10);
        make.width.mas_offset(10);
    }];
    
    [_labelFour mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_bigImageView.mas_bottom).with.offset(-10);
        make.left.equalTo(_imageViewFour.mas_right).with.offset(5);
        make.height.mas_offset(10);
        make.width.mas_offset(50);
    }];
    

}


@end
